% SegyMATdemo1 : Creates, Reads and plots a Segy File;
function main_plot(infile_name)

% choose a file name;
file=strcat('infiles/',infile_name,'.segy');
% file='infiles/residual_1layer_2layers.segy';

% Read the segy file with Segy Header and Segy Trace Header
[Data,STH,SH]=ReadSegy(file);

% x and y coordinates
x=[STH.TraceNumber];
t=SH.time;


% plot colorful image.
colormap (flipud(gray)) % 利用colormap改变color
xcoor=[-500 1500];
ycoor=[0 1500];
imagesc(xcoor, ycoor, Data);
% caxis([-2,3]); 
colorbar

% Appendix：图像title
title_name=strrep(infile_name,'_','\_');
title(title_name)
% xlabel('X position')
% ylabel('Depth  ')

% Appendix:输出图像文件
PicName=strcat(infile_name,'.png');
DirPicName=strcat('results/',PicName);
saveas(gcf,DirPicName)
% % plot gray imgage.
% imshow(Data, []);

end